package yxy.game.pm2.command.wuchao;

import yxy.cherry.game.base.message.MessageEmitterHandler;
import yxy.cherry.game.base.message.annotation.MessageSource;
import yxy.cherry.game.base.message.annotation.MessageType;
import yxy.game.pm2.Result;
import yxy.game.pm2.command.Command;
import yxy.game.pm2.message.WuchaoMessage;
import yxy.game.pm2.module.wuchao.WuchaoHandle;

/** 乌巢 乌巢界面 */
@MessageType(proto = Command.WuchaoUI, classtype = WuchaoMessage.WuchaoUIRequest.class)
public class CMD_WuchaoUI extends Command<WuchaoMessage.WuchaoUIRequest> {

	@Override
	public void execute(MessageSource messageSource, WuchaoMessage.WuchaoUIRequest request) {
		String playerCode = messageSource.getTag();

		WuchaoMessage.WuchaoUIResponse.Builder response = WuchaoMessage.WuchaoUIResponse.newBuilder();

		Result result = new WuchaoHandle().info(playerCode, response);

		send(messageSource, response, result);
	}

	private void send(MessageSource messageSource, WuchaoMessage.WuchaoUIResponse.Builder response, Result result) {
		response.setResult(result.packResult());
		MessageEmitterHandler.getInstance().send(messageSource, response.build());
	}
}